﻿<Window 
        x:Class="Sample2.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"  
        Closing="Window_Closing"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="24"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        
        <!-- Menu -->
        <Menu>
            <MenuItem Header="Dockable Contents">
                <MenuItem Header="Show" 
                          ItemsSource="{Binding DockableContents, ElementName=DockManager}" 
                          Click="OnShowDockableContent">
                    <MenuItem.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Title}"/>
                        </DataTemplate>
                    </MenuItem.ItemTemplate>
                </MenuItem>
                <MenuItem Header="Hidden" 
                          ItemsSource="{Binding HiddenContents}" 
                          Click="OnShowDockableContent">
                    <MenuItem.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Title}"/>
                        </DataTemplate>
                    </MenuItem.ItemTemplate>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Create New" Click="OnCreateNewDockableContent"/>
            </MenuItem>
            <MenuItem Header="Document Contents">
                <MenuItem Header="Show" ItemsSource="{Binding Documents, ElementName=DockManager}">
                    <MenuItem.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Title}"/>
                        </DataTemplate>
                    </MenuItem.ItemTemplate>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="Layout">
                <MenuItem Header="Save to text" Click="ExportLayoutToDocument"/>
                <MenuItem Header="Load from text" Click="ImportLayoutFromDocument"/>
            </MenuItem>
        </Menu>
        
        <!--Docking Manager AvalonDock-->
        <ad:DockingManager x:Name="DockManager" Grid.Row="1" Margin="0,4,0,0" Loaded="DockManager_Loaded">
            <ad:ResizingPanel Orientation="Horizontal" >
                <ad:DocumentPane/>
                <ad:DockablePane ad:ResizingPanel.ResizeWidth="0.5*">
                    <ad:DockableContent x:Name="logPane" Title="Log" DockableStyle="DockableToBorders" IsCloseable="False" ad:ResizingPanel.ResizeHeight="120">
                        <!--Text property must be bound to an application level source like Application.Current to
                        correctly work when content is dragged in another window!-->
                        <TextBox VerticalScrollBarVisibility="Auto"
                                 HorizontalScrollBarVisibility="Auto"
                                 IsReadOnly="True"
                                 Text="{Binding Path=MainWindow.StateChangeLog, Source={x:Static Application.Current}}"/>
                    </ad:DockableContent>
                </ad:DockablePane>
            </ad:ResizingPanel>
        </ad:DockingManager>
    </Grid>
</Window>
